<!DOCTYPE html>
<html>
<head>
    <title>添加专家</title>
    <#include "../../include/head-file.ftl"/>
    <link rel="stylesheet" href="${base}/static/ms-admin/4.7.2/css/index.css">
    <!-- 引入Vue 3 -->
    <script src="${base}/static/plugins/vue/3.4.25/vue.global.js"></script>
    <!-- 引入Element Plus -->
    <link rel="stylesheet" href="${base}/static/plugins/element-plus/2.7.1/index.css">
    <script src="${base}/static/plugins/element-plus/2.7.1/index.full.js"></script>
    <!-- 引入echarts -->
    <script src="${base}/static/plugins/echarts/echarts.min.js"></script>
    <style>
        .ms-container {
            margin: 0;
            padding: 10px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            height: calc(100vh - 20px);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .form-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 15px;
            padding-bottom: 8px;
            border-bottom: 1px solid #eee;
        }
        
        .top-buttons {
            display: flex;
            justify-content: flex-end;
            padding: 10px 0;
            border-bottom: 1px solid #ebeef5;
            margin-bottom: 10px;
        }
        
        .top-buttons .el-button {
            margin-left: 10px;
        }
        
        .collapse-panel {
            margin-bottom: 15px;
            border: 1px solid #EBEEF5;
            border-radius: 4px;
            overflow: hidden;
            padding: 15px;
            background-color: #fafafa;
        }
        
        .add-btn {
            margin-bottom: 15px;
            margin-top: 5px;
            background: linear-gradient(to right, #f0f8ff, #e6f3ff);
            color: #409EFF;
            border-color: #d9ecff;
            border-left: 4px solid #409EFF;
            font-weight: 500;
            padding-left: 15px;
            height: 36px;
        }
        
        .add-btn:hover {
            background: linear-gradient(to right, #e6f3ff, #d9ecff);
            color: #409EFF;
        }
        
        .add-btn i {
            margin-right: 5px;
        }
        
        .section-header {
            display: none; /* 隐藏多余的标题 */
        }
        
        .section-title-text {
            font-size: 16px;
            font-weight: 500;
            color: #303133;
        }
        
        .section-title {
            font-size: 16px;
            margin-bottom: 15px;
            color: #409EFF;
            background-color: #ecf5ff;
            padding: 8px 12px;
            border-radius: 4px;
            border-left: 4px solid #409EFF;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .delete-btn {
            color: #F56C6C !important;
            cursor: pointer;
            background-color: transparent;
            border: none;
        }
        
        .delete-btn:hover {
            opacity: 0.8;
        }
        
        .form-container {
            flex: 1;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }
        
        .scrollable-form {
            flex: 1;
            overflow-y: auto;
            padding-right: 5px;
        }
        
        .scrollable-section {
            max-height: none;
            padding-bottom: 20px;
        }
        
        /* 美化滚动条 */
        .scrollable-form::-webkit-scrollbar, .scrollable-section::-webkit-scrollbar {
            width: 8px;
        }
        
        .scrollable-form::-webkit-scrollbar-track, .scrollable-section::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 4px;
        }
        
        .scrollable-form::-webkit-scrollbar-thumb, .scrollable-section::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 4px;
        }
        
        .scrollable-form::-webkit-scrollbar-thumb:hover, .scrollable-section::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
        
        /* 避免底部内容被截断 */
        .el-collapse-item__content {
            padding-bottom: 25px !important;
        }
        
        /* 美化折叠面板标题 */
        .el-collapse-item__header {
            font-size: 16px;
            font-weight: bold;
            color: #303133;
            background: linear-gradient(to right, #f0f8ff, #ffffff);
            border-left: 4px solid #409EFF;
            padding-left: 15px;
            height: 48px;
            line-height: 48px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .el-collapse-item__header .header-left {
            display: flex;
            align-items: center;
        }
        
        .el-collapse-item__header .header-right {
            margin-right: 30px;
        }
        
        .el-collapse-item__header:hover {
            background: linear-gradient(to right, #e6f3ff, #ffffff);
        }
        
        /* 添加标题图标 */
        .header-icon {
            margin-right: 8px;
            font-size: 18px;
            color: #409EFF;
        }
        
        /* 确保表单在小屏幕上也能正常显示 */
        @media (max-height: 768px) {
            .ms-container {
                height: calc(100vh - 10px);
                margin: 0;
                padding: 5px;
            }
            
            .top-buttons {
                padding: 5px 0;
                margin-bottom: 5px;
            }
            
            .collapse-panel {
                padding: 10px;
                margin-bottom: 10px;
            }
        }
    </style>
</head>
<body>
<div id="form-app" class="ms-container">
    <!-- 顶部按钮 -->
    <div class="top-buttons">
        <el-button @click="handleReturn">返回</el-button>
        <el-button type="primary" @click="saveAll">保存</el-button>
    </div>
    
    <div class="form-container">
        <div class="scrollable-form">
            <el-form ref="expertForm" :model="formData" :rules="rules" label-width="120px" size="small">
                <!-- 折叠面板组 -->
                <el-collapse v-model="activeNames" @change="handleCollapseChange" accordion>
                    <!-- 专家基本信息 -->
                    <el-collapse-item name="1">
                        <template #title>
                            <div style="display: flex; justify-content: space-between; width: 100%; align-items: center;">
                                <div style="display: flex; align-items: center;">
                                    <span class="header-icon">
                                        <i class="el-icon-user"></i>
                                    </span>
                                    专家基本信息
                                </div>
                                <div>
                                    <el-button type="success" size="small" @click.stop="generateExpertSampleData" style="margin-right: 10px;">
                                        <i class="el-icon-data-line"></i> 生成样例数据
                                    </el-button>
                                    <el-button type="primary" size="small" @click.stop="addExpert" style="margin-right: 30px;">
                                        <i class="el-icon-plus"></i> 添加专家
                                    </el-button>
                                </div>
                            </div>
                        </template>
                        <div class="scrollable-section">
                            <div v-for="(expert, index) in formData.experts" :key="'expert-'+index" class="collapse-panel">
                                <div class="section-title">
                                    <span>专家 {{index + 1}}</span>
                                    <el-button type="danger" size="small" plain @click.prevent="removeExpert(index)">删除</el-button>
                                </div>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'专家编号'" :prop="'experts['+index+'].expertCode'">
                                            <el-input v-model="expert.expertCode" placeholder="例如：ZJ-004"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'姓名'" :prop="'experts['+index+'].name'">
                                            <el-input v-model="expert.name"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'性别'" :prop="'experts['+index+'].gender'">
                                            <el-select v-model="expert.gender" placeholder="请选择性别" style="width: 100%">
                                                <el-option label="男" value="男"></el-option>
                                                <el-option label="女" value="女"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'年龄'" :prop="'experts['+index+'].age'">
                                            <el-input-number v-model="expert.age" :min="1" :max="150" style="width: 100%"></el-input-number>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'职称/头衔'" :prop="'experts['+index+'].title'">
                                            <el-input v-model="expert.title"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'最高学历'" :prop="'experts['+index+'].highestEducation'">
                                            <el-select v-model="expert.highestEducation" placeholder="请选择学历" style="width: 100%">
                                                <el-option label="博士" value="博士"></el-option>
                                                <el-option label="硕士" value="硕士"></el-option>
                                                <el-option label="学士" value="学士"></el-option>
                                                <el-option label="其他" value="其他"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'一级学科'" :prop="'experts['+index+'].firstLevelDiscipline'">
                                            <el-input v-model="expert.firstLevelDiscipline"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'二级学科'" :prop="'experts['+index+'].secondLevelDiscipline'">
                                            <el-input v-model="expert.secondLevelDiscipline"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'校内/外标识'" :prop="'experts['+index+'].insideOutside'">
                                            <el-select v-model="expert.insideOutside" placeholder="请选择" style="width: 100%">
                                                <el-option label="校内" value="校内"></el-option>
                                                <el-option label="校外" value="校外"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'所属学院'" :prop="'experts['+index+'].college'">
                                            <el-input v-model="expert.college"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'社会职务'" :prop="'experts['+index+'].socialPositions'">
                                            <el-input v-model="expert.socialPositions" placeholder="例如：XX企业技术顾问"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'联系方式'" :prop="'experts['+index+'].contact'">
                                            <el-input v-model="expert.contact" placeholder="电话或邮箱"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'纵向项目数'" :prop="'experts['+index+'].verticalProjects'">
                                            <el-input v-model="expert.verticalProjects" placeholder="例如：国家级2项"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'横向项目数'" :prop="'experts['+index+'].horizontalProjects'">
                                            <el-input v-model="expert.horizontalProjects" placeholder="例如：企业合作3项"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'知识产权持有量'" :prop="'experts['+index+'].ipOwnership'">
                                            <el-input v-model="expert.ipOwnership" placeholder="例如：发明专利5项"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="24">
                                        <el-form-item :label="'研究方向关键词'" :prop="'experts['+index+'].researchKeywords'">
                                            <el-input v-model="expert.researchKeywords" type="textarea" rows="2" placeholder="多个关键词请用逗号分隔，建议3-5个"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="24">
                                        <el-form-item :label="'备注'" :prop="'experts['+index+'].remarks'">
                                            <el-input type="textarea" v-model="expert.remarks" :rows="3" placeholder="项目库 Z-001 负责人"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                        </div>
                    </el-collapse-item>
                    
                    <!-- 关联项目 -->
                    <el-collapse-item name="2">
                        <template #title>
                            <div style="display: flex; justify-content: space-between; width: 100%; align-items: center;">
                                <div style="display: flex; align-items: center;">
                                    <span class="header-icon">
                                        <i class="el-icon-folder"></i>
                                    </span>
                                    关联项目
                                </div>
                                <div>
                                    <el-button type="success" size="small" @click.stop="generateProjectSampleData" style="margin-right: 10px;">
                                        <i class="el-icon-data-line"></i> 生成样例数据
                                    </el-button>
                                    <el-button type="primary" size="small" @click.stop="addProject" style="margin-right: 30px;">
                                        <i class="el-icon-plus"></i> 添加项目
                                    </el-button>
                                </div>
                            </div>
                        </template>
                        <div class="scrollable-section">
                            <div v-for="(project, index) in formData.projects" :key="'project-'+index" class="collapse-panel">
                                <div class="section-title">
                                    <span>项目 {{index + 1}}</span>
                                    <el-button type="danger" size="small" plain @click.prevent="removeProject(index)">删除</el-button>
                                </div>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'项目编号'" :prop="'projects['+index+'].projectCode'">
                                            <el-input v-model="project.projectCode" placeholder="例如：Z-001"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'项目名称'" :prop="'projects['+index+'].projectName'">
                                            <el-input v-model="project.projectName" placeholder="项目名称"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'所属部门'" :prop="'projects['+index+'].department'">
                                            <el-input v-model="project.department" placeholder="所属部门"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'负责人编号'" :prop="'projects['+index+'].leaderCode'">
                                            <el-input v-model="project.leaderCode" placeholder="例如：ZJ-001"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'参与专家'" :prop="'projects['+index+'].participantExperts'">
                                            <el-input v-model="project.participantExperts" placeholder="多个专家编号用逗号分隔"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'项目类型'" :prop="'projects['+index+'].projectType'">
                                            <el-select v-model="project.projectType" placeholder="请选择" style="width: 100%">
                                                <el-option label="产品类" value="产品类"></el-option>
                                                <el-option label="服务类" value="服务类"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'技术成熟度'" :prop="'projects['+index+'].techMaturity'">
                                            <el-select v-model="project.techMaturity" placeholder="请选择" style="width: 100%">
                                                <el-option label="TRL7（中试阶段）" value="TRL7（中试阶段）"></el-option>
                                                <el-option label="TRL9（商业化）" value="TRL9（商业化）"></el-option>
                                                <el-option label="TRL5（样机阶段）" value="TRL5（样机阶段）"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'市场化阶段'" :prop="'projects['+index+'].marketStage'">
                                            <el-input v-model="project.marketStage" placeholder="市场化阶段"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'预算需求'" :prop="'projects['+index+'].budget'">
                                            <el-input v-model="project.budget" placeholder="例如：2000万元"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'核心技术关键词'" :prop="'projects['+index+'].coreTechKeywords'">
                                            <el-input v-model="project.coreTechKeywords" placeholder="多个关键词用逗号分隔"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'应用行业'" :prop="'projects['+index+'].applicationIndustry'">
                                            <el-input v-model="project.applicationIndustry" placeholder="应用行业"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'合作企业意向'" :prop="'projects['+index+'].cooperationTendency'">
                                            <el-input v-model="project.cooperationTendency" placeholder="企业库编号，用逗号分隔"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="24">
                                        <el-form-item :label="'备注'" :prop="'projects['+index+'].remarks'">
                                            <el-input type="textarea" v-model="project.remarks" :rows="2" placeholder="备注信息"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                        </div>
                    </el-collapse-item>
                    
                    <!-- 关联企业 -->
                    <el-collapse-item name="3">
                        <template #title>
                            <div style="display: flex; justify-content: space-between; width: 100%; align-items: center;">
                                <div style="display: flex; align-items: center;">
                                    <span class="header-icon">
                                        <i class="el-icon-office-building"></i>
                                    </span>
                                    关联企业
                                </div>
                                <div>
                                    <el-button type="success" size="small" @click.stop="generateCompanySampleData" style="margin-right: 10px;">
                                        <i class="el-icon-data-line"></i> 生成样例数据
                                    </el-button>
                                    <el-button type="primary" size="small" @click.stop="addCompany" style="margin-right: 30px;">
                                        <i class="el-icon-plus"></i> 添加企业
                                    </el-button>
                                </div>
                            </div>
                        </template>
                        <div class="scrollable-section">
                            <div v-for="(company, index) in formData.companies" :key="'company-'+index" class="collapse-panel">
                                <div class="section-title">
                                    <span>企业 {{index + 1}}</span>
                                    <el-button type="danger" size="small" plain @click.prevent="removeCompany(index)">删除</el-button>
                                </div>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'企业编号'" :prop="'companies['+index+'].companyCode'">
                                            <el-input v-model="company.companyCode" placeholder="例如：QY-001"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'企业名称'" :prop="'companies['+index+'].companyName'">
                                            <el-input v-model="company.companyName" placeholder="企业名称"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'企业类型'" :prop="'companies['+index+'].companyType'">
                                            <el-input v-model="company.companyType" placeholder="例如：本地规上企业"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'所属行业(一级)'" :prop="'companies['+index+'].industryPrimary'">
                                            <el-input v-model="company.industryPrimary" placeholder="例如：新能源"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'所属行业(二级)'" :prop="'companies['+index+'].industrySecondary'">
                                            <el-input v-model="company.industrySecondary" placeholder="例如：动力电池回收"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'注册地址'" :prop="'companies['+index+'].registrationAddress'">
                                            <el-input v-model="company.registrationAddress" placeholder="例如：掇刀区"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="8">
                                        <el-form-item :label="'联系人'" :prop="'companies['+index+'].contactPerson'">
                                            <el-input v-model="company.contactPerson" placeholder="例如：刘经理"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'联系方式'" :prop="'companies['+index+'].contactInfo'">
                                            <el-input v-model="company.contactInfo" placeholder="例如：0724-8888888"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item :label="'合作状态'" :prop="'companies['+index+'].cooperationStatus'">
                                            <el-select v-model="company.cooperationStatus" placeholder="请选择" style="width: 100%">
                                                <el-option label="深度合作" value="深度合作"></el-option>
                                                <el-option label="意向对接" value="意向对接"></el-option>
                                                <el-option label="签约合作" value="签约合作"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <el-form-item :label="'主营业务关键词'" :prop="'companies['+index+'].businessKeywords'">
                                            <el-input v-model="company.businessKeywords" placeholder="多个关键词用逗号分隔"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item :label="'需求技术领域'" :prop="'companies['+index+'].requiredTechField'">
                                            <el-input v-model="company.requiredTechField" placeholder="多个领域用逗号分隔"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row :gutter="20">
                                    <el-col :span="24">
                                        <el-form-item :label="'备注'" :prop="'companies['+index+'].remarks'">
                                            <el-input type="textarea" v-model="company.remarks" :rows="2" placeholder="备注信息"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </div>
                        </div>
                    </el-collapse-item>
                </el-collapse>
            </el-form>
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 创建Vue应用实例
        const app = Vue.createApp({
            data() {
                return {
                    activeNames: ['1'],  // 默认展开第一个面板
                    formData: {
                        experts: [],
                        projects: [],
                        companies: []
                    },
                    rules: {
                        'experts[0].expertCode': [
                            { required: true, message: '请输入专家编号', trigger: 'blur' }
                        ],
                        'experts[0].name': [
                            { required: true, message: '请输入专家姓名', trigger: 'blur' }
                        ],
                        'experts[0].gender': [
                            { required: true, message: '请选择性别', trigger: 'change' }
                        ],
                        'experts[0].age': [
                            { required: true, message: '请输入年龄', trigger: 'blur' }
                        ],
                        'experts[0].title': [
                            { required: true, message: '请输入职称/头衔', trigger: 'blur' }
                        ],
                        'experts[0].highestEducation': [
                            { required: true, message: '请选择最高学历', trigger: 'change' }
                        ],
                        'experts[0].college': [
                            { required: true, message: '请输入所属学院', trigger: 'blur' }
                        ],
                        'experts[0].insideOutside': [
                            { required: true, message: '请选择校内/外标识', trigger: 'change' }
                        ],
                        'experts[0].researchKeywords': [
                            { required: true, message: '请输入研究方向关键词', trigger: 'blur' }
                        ]
                    }
                };
            },
            methods: {
                // 处理折叠面板变化
                handleCollapseChange(activeNames) {
                    // 如果打开专家面板且没有专家信息，自动添加一个
                    if (activeNames.includes('1') && this.formData.experts.length === 0) {
                        this.addExpert();
                    }
                    
                    // 如果打开项目面板且没有项目信息，自动添加一个
                    if (activeNames.includes('2') && this.formData.projects.length === 0) {
                        this.addProject();
                    }
                    
                    // 如果打开企业面板且没有企业信息，自动添加一个
                    if (activeNames.includes('3') && this.formData.companies.length === 0) {
                        this.addCompany();
                    }
                },
                
                // 添加专家
                addExpert: function() {
                    this.formData.experts.push({
                        serialNo: ${nextSerialNo},
                        expertCode: '',
                        name: '',
                        gender: '',
                        age: null,
                        title: '',
                        highestEducation: '',
                        firstLevelDiscipline: '',
                        secondLevelDiscipline: '',
                        college: '',
                        insideOutside: '',
                        researchKeywords: '',
                        achievementType: '',
                        ipOwnership: '',
                        socialPositions: '',
                        verticalProjects: '',
                        horizontalProjects: '',
                        contact: '',
                        remarks: ''
                    });
                },
                
                // 移除专家
                removeExpert: function(index) {
                    this.formData.experts.splice(index, 1);
                    // 如果删除后没有专家，自动添加一个
                    if (this.formData.experts.length === 0) {
                        this.addExpert();
                    }
                },
                
                // 添加项目
                addProject: function() {
                    this.formData.projects.push({
                        projectCode: '',
                        projectName: '',
                        department: '',
                        leaderCode: this.formData.experts.length > 0 ? this.formData.experts[0].expertCode : '',  // 默认关联第一个专家
                        participantExperts: '',
                        projectType: '',
                        techMaturity: '',
                        coreTechKeywords: '',
                        applicationIndustry: '',
                        marketStage: '',
                        budget: '',
                        cooperationTendency: '',
                        remarks: ''
                    });
                },
                
                // 移除项目
                removeProject: function(index) {
                    this.formData.projects.splice(index, 1);
                    // 如果删除后没有项目且项目面板是打开的，自动添加一个
                    if (this.formData.projects.length === 0 && this.activeNames.includes('2')) {
                        this.addProject();
                    }
                },
                
                // 添加企业
                addCompany: function() {
                    this.formData.companies.push({
                        companyCode: '',
                        companyName: '',
                        companyType: '',
                        industryPrimary: '',
                        industrySecondary: '',
                        registrationAddress: '',
                        contactPerson: '',
                        contactInfo: '',
                        businessKeywords: '',
                        requiredTechField: '',
                        cooperationStatus: '',
                        remarks: ''
                    });
                },
                
                // 移除企业
                removeCompany: function(index) {
                    this.formData.companies.splice(index, 1);
                    // 如果删除后没有企业且企业面板是打开的，自动添加一个
                    if (this.formData.companies.length === 0 && this.activeNames.includes('3')) {
                        this.addCompany();
                    }
                },
                
                // 生成专家样例数据
                generateExpertSampleData: function() {
                    // 确保至少有一个专家
                    if (this.formData.experts.length === 0) {
                        this.addExpert();
                    }
                    
                    // 名字库
                    const firstNames = ['张', '李', '王', '赵', '钱', '孙', '周', '吴', '郑', '冯', '陈', '楚', '卫', '蒋', '沈', '韩', '杨', '朱'];
                    const lastNames = ['伟', '芳', '娜', '秀英', '敏', '静', '丽', '强', '磊', '军', '洋', '勇', '艳', '杰', '娟', '涛', '明', '超'];
                    
                    // 一级学科
                    const firstDisciplines = ['材料科学与工程', '机械工程', '电气工程', '计算机科学与技术', '自动化', '生物医学工程'];
                    
                    // 二级学科映射
                    const secondDisciplines = {
                        '材料科学与工程': ['新能源材料', '功能材料', '复合材料', '纳米材料'],
                        '机械工程': ['智能装备', '机械设计', '机械制造', '流体机械'],
                        '电气工程': ['电力系统', '电气自动化', '电力电子', '智能电网'],
                        '计算机科学与技术': ['软件工程', '数据科学', '人工智能', '网络安全'],
                        '自动化': ['控制理论', '智能控制', '模式识别', '工业自动化'],
                        '生物医学工程': ['生物医药', '医学影像', '生物材料', '组织工程']
                    };
                    
                    // 学院
                    const colleges = ['材料学院', '机械学院', '电气学院', '计算机学院', '自动化学院', '生物医学院'];
                    
                    // 研究关键词库
                    const researchKeywords = {
                        '材料科学与工程': ['锂电池', '固态电解质', '电催化', '石墨烯', '薄膜材料', '磁性材料'],
                        '机械工程': ['工业机器人', '故障诊断', '自动化', '智能制造', '精密加工', '3D打印'],
                        '电气工程': ['电力电子', '智能电网', '电机控制', '可再生能源', '微电网', '配电系统'],
                        '计算机科学与技术': ['人工智能', '大数据', '云计算', '区块链', '物联网', '机器学习'],
                        '自动化': ['控制系统', '智能控制', '模式识别', '传感器网络', '无人系统', '过程控制'],
                        '生物医学工程': ['靶向药物', '纳米载体', '合成化学', '生物传感', '医学成像', '组织工程']
                    };
                    
                    // 随机生成
                    const randomFirstName = firstNames[Math.floor(Math.random() * firstNames.length)];
                    const randomLastName = lastNames[Math.floor(Math.random() * lastNames.length)];
                    const name = randomFirstName + randomLastName;
                    
                    const gender = Math.random() > 0.5 ? '男' : '女';
                    const age = Math.floor(Math.random() * 30) + 35; // 35-65岁
                    
                    const titles = ['教授', '副教授', '研究员', '副研究员', '高级工程师', '讲师'];
                    const title = titles[Math.floor(Math.random() * titles.length)];
                    
                    const education = ['博士', '硕士', '博士后'];
                    const highestEducation = education[Math.floor(Math.random() * education.length)];
                    
                    const firstDiscipline = firstDisciplines[Math.floor(Math.random() * firstDisciplines.length)];
                    const secondDisciplineOptions = secondDisciplines[firstDiscipline] || ['软件工程', '数据科学'];
                    const secondDiscipline = secondDisciplineOptions[Math.floor(Math.random() * secondDisciplineOptions.length)];
                    
                    const college = colleges[Math.floor(Math.random() * colleges.length)];
                    const insideOutside = Math.random() > 0.2 ? '校内' : '校外';
                    
                    // 生成研究方向关键词
                    const availableKeywords = researchKeywords[firstDiscipline] || ['人工智能', '大数据', '云计算'];
                    const keywordsCount = Math.floor(Math.random() * 3) + 3; // 3-5个关键词
                    const shuffledKeywords = [...availableKeywords].sort(() => 0.5 - Math.random());
                    const selectedKeywords = shuffledKeywords.slice(0, keywordsCount);
                    const researchKeywordsStr = selectedKeywords.join(', ');
                    
                    // 生成专家编号 ZJ-xxx
                    const expertCodeNum = Math.floor(Math.random() * 900) + 100; // 100-999
                    const expertCode = 'ZJ-' + expertCodeNum;
                    
                    // 生成IP信息
                    const patentCount = Math.floor(Math.random() * 10) + 1;
                    const ipTypes = ['发明专利', '实用新型专利', '软件著作权', '国际专利'];
                    const ipType = ipTypes[Math.floor(Math.random() * ipTypes.length)];
                    const ipOwnership = ipType + ' ' + patentCount + ' 项';
                    
                    // 生成项目信息
                    const verticalProjectCount = Math.floor(Math.random() * 3) + 1;
                    const verticalProjectTypes = ['国家级', '省部级', '市厅级'];
                    const verticalProjectType = verticalProjectTypes[Math.floor(Math.random() * verticalProjectTypes.length)];
                    const verticalProjects = verticalProjectType + ' ' + verticalProjectCount + ' 项';
                    
                    const horizontalProjectCount = Math.floor(Math.random() * 5) + 1;
                    const horizontalProjects = '企业合作 ' + horizontalProjectCount + ' 项';
                    
                    // 生成社会职务
                    const companies = ['格林美', '新洋丰', '健帆生物', '星网宇达', '长源动力', '亿纬锂能'];
                    const company = companies[Math.floor(Math.random() * companies.length)];
                    const positions = ['技术顾问', '独立董事', '首席科学家', '专家委员'];
                    const position = positions[Math.floor(Math.random() * positions.length)];
                    const socialPositions = company + '（荆门）' + position;
                    
                    // 生成联系方式
                    const domains = ['hust.edu', 'jmtc.edu', 'opticvalley.com', 'university.edu.cn'];
                    const domain = domains[Math.floor(Math.random() * domains.length)];
                    const pinyin = this.getPinyin(name);
                    const contact = pinyin + '@' + domain;
                    
                    // 生成备注信息
                    const projectNum = Math.floor(Math.random() * 20) + 1;
                    let projectNumStr = '';
                    if (projectNum < 10) {
                        projectNumStr = '00' + projectNum;
                    } else {
                        projectNumStr = '0' + projectNum;
                    }
                    const remarks = '项目库 Z-' + projectNumStr + ' 负责人';
                    
                    // 填充专家测试数据到第一个专家
                    this.formData.experts[0].expertCode = expertCode;
                    this.formData.experts[0].name = name;
                    this.formData.experts[0].gender = gender;
                    this.formData.experts[0].age = age;
                    this.formData.experts[0].title = title;
                    this.formData.experts[0].highestEducation = highestEducation;
                    this.formData.experts[0].firstLevelDiscipline = firstDiscipline;
                    this.formData.experts[0].secondLevelDiscipline = secondDiscipline;
                    this.formData.experts[0].college = college;
                    this.formData.experts[0].insideOutside = insideOutside;
                    this.formData.experts[0].researchKeywords = researchKeywordsStr;
                    this.formData.experts[0].ipOwnership = ipOwnership;
                    this.formData.experts[0].socialPositions = socialPositions;
                    this.formData.experts[0].verticalProjects = verticalProjects;
                    this.formData.experts[0].horizontalProjects = horizontalProjects;
                    this.formData.experts[0].contact = contact;
                    this.formData.experts[0].remarks = remarks;
                    
                    ElementPlus.ElNotification({
                        title: '成功',
                        message: '专家样例数据已生成',
                        type: 'success'
                    });
                },
                
                // 中文转拼音简化方法
                getPinyin: function(name) {
                    // 简单转换姓氏
                    const pinyinMap = {
                        '张': 'zhang', '李': 'li', '王': 'wang', '赵': 'zhao',
                        '钱': 'qian', '孙': 'sun', '周': 'zhou', '吴': 'wu',
                        '郑': 'zheng', '冯': 'feng', '陈': 'chen', '楚': 'chu',
                        '卫': 'wei', '蒋': 'jiang', '沈': 'shen', '韩': 'han',
                        '杨': 'yang', '朱': 'zhu'
                    };
                    
                    // 简单处理，取第一个字符作为姓氏
                    const firstName = name.charAt(0);
                    const pinyin = pinyinMap[firstName] || 'user';
                    
                    // 添加随机数
                    const randomNum = Math.floor(Math.random() * 1000);
                    return pinyin + randomNum;
                },
                
                // 生成项目样例数据
                generateProjectSampleData: function() {
                    // 确保至少有一个项目
                    if (this.formData.projects.length === 0) {
                        this.addProject();
                    }
                    
                    // 项目名称前缀和后缀
                    const prefixes = ['高能量密度', '低成本', '高效率', '智能化', '自动化', '绿色环保', '新型', '高性能'];
                    const projectTypes = ['固态锂电池', '工业机器人', '故障诊断系统', '智能制造平台', '电控系统', '材料合成工艺', '抗肿瘤纳米药物'];
                    
                    // 部门
                    const departments = ['新能源材料所', '智能装备所', '电气自动化所', '计算机技术所', '生物医药所', '化工工程所'];
                    
                    // 生成基本信息
                    const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
                    const projectType = projectTypes[Math.floor(Math.random() * projectTypes.length)];
                    const projectName = prefix + projectType;
                    const department = departments[Math.floor(Math.random() * departments.length)];
                    
                    // 生成项目编号 Z-xxx
                    const projectCodeNum = Math.floor(Math.random() * 900) + 100; // 100-999
                    const projectCode = 'Z-' + projectCodeNum;
                    
                    // 获取或生成负责人编号
                    let leaderCode = this.formData.experts.length > 0 ? this.formData.experts[0].expertCode : '';
                    if (!leaderCode) {
                        const leaderCodeNum = Math.floor(Math.random() * 900) + 100;
                        leaderCode = 'ZJ-' + leaderCodeNum;
                    }
                    
                    // 生成参与专家编号
                    const participantCount = Math.floor(Math.random() * 3) + 1;
                    let participantExperts = [];
                    for (let i = 0; i < participantCount; i++) {
                        const expertNum = Math.floor(Math.random() * 900) + 100;
                        participantExperts.push('ZJ-' + expertNum);
                    }
                    const participantExpertsStr = participantExperts.join(', ');
                    
                    // 项目类型
                    const types = ['产品类', '服务类', '咨询类', '平台类'];
                    const type = types[Math.floor(Math.random() * types.length)];
                    
                    // 技术成熟度
                    const techMaturities = ['TRL5（样机阶段）', 'TRL6（测试验证）', 'TRL7（中试阶段）', 'TRL8（小规模应用）', 'TRL9（商业化）'];
                    const techMaturity = techMaturities[Math.floor(Math.random() * techMaturities.length)];
                    
                    // 核心技术关键词
                    const coreKeywordsLib = {
                        '固态锂电池': ['固态电解质', '界面改性', '高能量密度', '离子传导', '电极材料'],
                        '工业机器人': ['机器学习', '故障预测', '智能控制', '轨迹规划', '多轴协同'],
                        '故障诊断系统': ['机器学习', '故障预测', '振动分析', '模式识别', '专家系统'],
                        '智能制造平台': ['数字孪生', '工业互联网', '大数据分析', '智能调度', '预测维护'],
                        '电控系统': ['电机控制', '电力电子', '智能驱动', '功率优化', '闭环控制'],
                        '材料合成工艺': ['催化合成', '机械活化', '溶胶凝胶', '水热合成', '微波辅助'],
                        '抗肿瘤纳米药物': ['纳米载体', '靶向递送', '控制释放', '生物相容性', '肿瘤微环境']
                    };
                    
                    const defaultKeywords = ['创新技术', '智能算法', '高效处理', '节能环保', '精准控制'];
                    const availableKeywords = coreKeywordsLib[projectType] || defaultKeywords;
                    const keywordsCount = Math.floor(Math.random() * 2) + 2; // 2-3个关键词
                    const shuffledKeywords = [...availableKeywords].sort(() => 0.5 - Math.random());
                    const selectedKeywords = shuffledKeywords.slice(0, keywordsCount);
                    const coreTechKeywords = selectedKeywords.join(', ');
                    
                    // 应用行业
                    const industriesLib = {
                        '固态锂电池': ['新能源汽车', '储能', '电子设备'],
                        '工业机器人': ['机械制造', '电子加工', '自动化生产'],
                        '故障诊断系统': ['设备运维', '智能制造', '工业互联网'],
                        '智能制造平台': ['离散制造', '流程工业', '智能工厂'],
                        '电控系统': ['汽车电子', '工业控制', '智能家居'],
                        '材料合成工艺': ['新材料', '化工', '能源'],
                        '抗肿瘤纳米药物': ['制药', 'CRO', '生物医药']
                    };
                    
                    const defaultIndustries = ['高新技术', '制造业', '信息技术'];
                    const availableIndustries = industriesLib[projectType] || defaultIndustries;
                    const industry1 = availableIndustries[0] || '高新技术';
                    const industry2 = availableIndustries.length > 1 ? availableIndustries[1] : '制造业';
                    const applicationIndustry = industry1 + ' / ' + industry2 + '（对应企业库行业分类）';
                    
                    // 市场化阶段
                    const marketStages = ['实验室阶段', '样品测试', '中试阶段', '市场推广', '商业化运营'];
                    const marketStage = marketStages[Math.floor(Math.random() * marketStages.length)];
                    
                    // 预算需求
                    const budgetBase = [500, 800, 1000, 1500, 2000, 3000];
                    const budgetValue = budgetBase[Math.floor(Math.random() * budgetBase.length)];
                    const budget = budgetValue + '万元';
                    
                    // 合作企业意向
                    const companies = ['QY-001（格林美）', 'QY-002（新洋丰）', 'QY-003（长源动力）', 'QY-004（亿纬锂能）', 'QY-005（健帆生物）'];
                    const companyIndex1 = Math.floor(Math.random() * companies.length);
                    let companyIndex2;
                    do {
                        companyIndex2 = Math.floor(Math.random() * companies.length);
                    } while (companyIndex2 === companyIndex1);
                    
                    const cooperationTendency = companies[companyIndex1] + (Math.random() > 0.5 ? ', ' + companies[companyIndex2] : '');
                    
                    // 备注
                    const companyCodeMatch = cooperationTendency.match(/QY-\d+/);
                    const companyCode = companyCodeMatch ? companyCodeMatch[0] : 'QY-001';
                    const remarks = '关联企业库 ' + companyCode;
                    
                    // 填充项目测试数据
                    this.formData.projects[0].projectCode = projectCode;
                    this.formData.projects[0].projectName = projectName;
                    this.formData.projects[0].department = department;
                    this.formData.projects[0].leaderCode = leaderCode;
                    this.formData.projects[0].participantExperts = participantExpertsStr;
                    this.formData.projects[0].projectType = type;
                    this.formData.projects[0].techMaturity = techMaturity;
                    this.formData.projects[0].coreTechKeywords = coreTechKeywords;
                    this.formData.projects[0].applicationIndustry = applicationIndustry;
                    this.formData.projects[0].marketStage = marketStage;
                    this.formData.projects[0].budget = budget;
                    this.formData.projects[0].cooperationTendency = cooperationTendency;
                    this.formData.projects[0].remarks = remarks;
                    
                    ElementPlus.ElNotification({
                        title: '成功',
                        message: '项目样例数据已生成',
                        type: 'success'
                    });
                },
                
                // 生成企业样例数据
                generateCompanySampleData: function() {
                    // 确保至少有一个企业
                    if (this.formData.companies.length === 0) {
                        this.addCompany();
                    }
                    
                    // 企业名称库
                    const companyNames = ['格林美', '新洋丰', '健帆生物', '星网宇达', '长源动力', '亿纬锂能', '南兴装备', '科大国创', '蓝思科技', '中材科技'];
                    
                    // 企业类型
                    const companyTypes = ['本地规上企业', '本地龙头企业', '友好企业', '高新技术企业', '上市公司', '外资企业', '国有企业'];
                    
                    // 一级行业和对应的二级行业
                    const industries = {
                        '新能源': ['动力电池回收', '储能系统', '光伏组件', '氢能技术', '风电设备'],
                        '化工/农业': ['化肥制造', '农药生产', '精细化工', '生物农药', '化工新材料'],
                        '生物医药': ['靶向药物', '医疗器械', '体外诊断', '药物中间体', '生物技术'],
                        '制造业': ['智能装备', '机械加工', '精密制造', '自动化设备', '工业机器人'],
                        '信息技术': ['软件开发', '大数据服务', '云计算', '人工智能', '物联网技术'],
                        '新材料': ['先进复合材料', '高性能金属材料', '功能陶瓷', '特种高分子', '纳米材料']
                    };
                    
                    // 注册地址
                    const addresses = ['掇刀区', '东宝区', '高新区', '荆门开发区', '沙洋县', '钟祥市', '京山市'];
                    
                    // 合作状态
                    const cooperationStatus = ['深度合作', '意向对接', '签约合作', '洽谈中', '初步接触'];
                    
                    // 生成随机数据
                    const companyName = companyNames[Math.floor(Math.random() * companyNames.length)];
                    const companyType = companyTypes[Math.floor(Math.random() * companyTypes.length)];
                    
                    // 生成企业编号 QY-xxx
                    const companyCodeNum = Math.floor(Math.random() * 900) + 100; // 100-999
                    const companyCode = 'QY-' + companyCodeNum;
                    
                    // 随机选择行业
                    const industryKeys = Object.keys(industries);
                    const industryPrimary = industryKeys[Math.floor(Math.random() * industryKeys.length)];
                    const industrySecondaryOptions = industries[industryPrimary];
                    const industrySecondary = industrySecondaryOptions[Math.floor(Math.random() * industrySecondaryOptions.length)];
                    
                    const registrationAddress = addresses[Math.floor(Math.random() * addresses.length)];
                    
                    // 联系人姓氏和头衔
                    const contactLastNames = ['张', '李', '王', '赵', '钱', '孙', '周', '吴', '郑', '陈'];
                    const contactTitles = ['经理', '总监', '部长', '工程师', '主任', '总工'];
                    const contactPersonLastName = contactLastNames[Math.floor(Math.random() * contactLastNames.length)];
                    const contactPersonTitle = contactTitles[Math.floor(Math.random() * contactTitles.length)];
                    const contactPerson = contactPersonLastName + contactPersonTitle;
                    
                    // 联系方式 - 固定电话或手机
                    const contactType = Math.random() > 0.5 ? 'phone' : 'mobile';
                    let contactInfo;
                    if (contactType === 'phone') {
                        // 0724-xxxxxxx
                        const randomNum = Math.floor(Math.random() * 9000000) + 1000000;
                        contactInfo = '0724-' + randomNum;
                    } else {
                        // 13x/15x/18x xxxxxxxx
                        const prefixes = ['130', '131', '132', '133', '134', '135', '136', '137', '138', '139', '150', '151', '152', '158', '159', '182', '183', '184', '185', '186', '187', '188', '189'];
                        const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];
                        const randomNumBase = Math.floor(Math.random() * 100000000);
                        // 手动补全至8位数字
                        let randomNum = randomNumBase.toString();
                        while (randomNum.length < 8) {
                            randomNum = '0' + randomNum;
                        }
                        contactInfo = prefix + randomNum;
                    }
                    
                    // 企业主营业务关键词
                    const businessKeywordsLib = {
                        '新能源': ['电池回收', '材料再生', '储能设备', '光伏发电', '氢能利用', '清洁能源'],
                        '化工/农业': ['化肥生产', '土壤修复', '农业投入品', '绿色化工', '生物技术', '植保技术'],
                        '生物医药': ['医药中间体', '医疗设备', '生物技术', '诊断试剂', '制剂生产', '康复医疗'],
                        '制造业': ['精密加工', '自动化生产', '数控设备', '工业机器人', '智能制造', '工装夹具'],
                        '信息技术': ['软件开发', '系统集成', '数据服务', '云计算平台', '智能算法', '行业解决方案'],
                        '新材料': ['高分子材料', '复合材料', '金属新材料', '陶瓷材料', '功能薄膜', '特种纤维']
                    };
                    
                    const availableBusinessKeywords = businessKeywordsLib[industryPrimary] || ['创新技术', '智能制造', '绿色生产'];
                    const keywordsCount = Math.floor(Math.random() * 2) + 2; // 2-3个关键词
                    const shuffledKeywords = [...availableBusinessKeywords].sort(() => 0.5 - Math.random());
                    const selectedKeywords = shuffledKeywords.slice(0, keywordsCount);
                    const businessKeywords = selectedKeywords.join(', ');
                    
                    // 需求技术领域
                    const techFieldsLib = {
                        '新能源': ['新能源材料', '电池管理系统', '能源存储', '智能电网', '氢能利用'],
                        '化工/农业': ['精准农业', '智能装备', '绿色肥料', '土壤改良', '废物资源化'],
                        '生物医药': ['生物医药', '纳米载体', '医学影像', '生物传感', '医疗器械'],
                        '制造业': ['智能制造', '工业互联网', '精密控制', '数字孪生', '自动化'],
                        '信息技术': ['人工智能', '区块链', '大数据', '边缘计算', '网络安全'],
                        '新材料': ['材料表征', '功能材料', '结构材料', '复合材料', '纳米材料']
                    };
                    
                    const availableTechFields = techFieldsLib[industryPrimary] || ['自动化控制', '信息技术', '材料科学'];
                    const techFieldCount = Math.floor(Math.random() * 2) + 1; // 1-2个领域
                    const shuffledTechFields = [...availableTechFields].sort(() => 0.5 - Math.random());
                    const selectedTechFields = shuffledTechFields.slice(0, techFieldCount);
                    const requiredTechField = selectedTechFields.join(', ');
                    
                    // 合作状态
                    const status = cooperationStatus[Math.floor(Math.random() * cooperationStatus.length)];
                    
                    // 备注
                    let remarks = '';
                    if (status === '深度合作' || status === '签约合作') {
                        // 专家编号 ZJ-xxx
                        const expertNum = Math.floor(Math.random() * 900) + 100;
                        remarks = '专家库 ZJ-' + expertNum + ' 为技术顾问';
                    } else if (status === '意向对接') {
                        // 专家编号 ZJ-xxx
                        const expertNum = Math.floor(Math.random() * 900) + 100;
                        remarks = '需求匹配专家库 ZJ-' + expertNum;
                    } else {
                        remarks = '待进一步对接';
                    }
                    
                    // 填充企业测试数据
                    this.formData.companies[0].companyCode = companyCode;
                    this.formData.companies[0].companyName = companyName;
                    this.formData.companies[0].companyType = companyType;
                    this.formData.companies[0].industryPrimary = industryPrimary;
                    this.formData.companies[0].industrySecondary = industrySecondary;
                    this.formData.companies[0].registrationAddress = registrationAddress;
                    this.formData.companies[0].contactPerson = contactPerson;
                    this.formData.companies[0].contactInfo = contactInfo;
                    this.formData.companies[0].businessKeywords = businessKeywords;
                    this.formData.companies[0].requiredTechField = requiredTechField;
                    this.formData.companies[0].cooperationStatus = status;
                    this.formData.companies[0].remarks = remarks;
                    
                    ElementPlus.ElNotification({
                        title: '成功',
                        message: '企业样例数据已生成',
                        type: 'success'
                    });
                },
                
                // 保存所有信息
                saveAll: function() {
                    var that = this;
                    
                    // 打印表单数据以调试
                    console.log("提交的表单数据：", JSON.stringify(that.formData));
                    
                    this.$refs.expertForm.validate(function(valid) {
                        if (valid) {
                            // 检查至少有一个专家信息
                            if (that.formData.experts.length === 0) {
                                ElementPlus.ElNotification({
                                    title: '提示',
                                    message: '请至少添加一个专家信息',
                                    type: 'warning'
                                });
                                return false;
                            }
                            
                            try {
                                // 将数据结构修改为后端期望的格式
                                var submitData = {
                                    expert: that.formData.experts[0], // 使用第一个专家数据
                                    projects: that.formData.projects,
                                    companies: that.formData.companies
                                };
                                
                                // 保存专家信息 - 修改请求方式确保使用JSON格式
                                ms.http.post(ms.manager + "/expertmanage/expert/saveRelations", 
                                    submitData,  // 直接传对象，不使用JSON.stringify
                                    {
                                        headers: {
                                            'Content-Type': 'application/json;charset=UTF-8'  // 确保Content-Type正确
                                        }
                                    }
                                )
                                .then(function(res) {
                                    console.log("保存结果：", res);
                                    if (res.result) {
                                        ElementPlus.ElNotification({
                                            title: '成功',
                                            message: '信息保存成功',
                                            type: 'success'
                                        });
                                        // 保存成功后跳转到列表页
                                        setTimeout(function() {
                                            location.href = ms.manager + "/expertmanage/relation/index";
                                        }, 1500);
                                    } else {
                                        ElementPlus.ElNotification({
                                            title: '失败',
                                            message: res.msg || '保存失败',
                                            type: 'error'
                                        });
                                    }
                                })
                                .catch(function(err) {
                                    console.error("保存错误：", err);
                                    ElementPlus.ElNotification({
                                        title: '错误',
                                        message: '系统异常，请稍后重试: ' + (err.message || err),
                                        type: 'error'
                                    });
                                });
                            } catch (e) {
                                console.error("提交数据处理错误：", e);
                                ElementPlus.ElNotification({
                                    title: '错误',
                                    message: '数据处理错误：' + e.message,
                                    type: 'error'
                                });
                            }
                        } else {
                            return false;
                        }
                    });
                },
                
                // 返回按钮
                handleReturn: function() {
                    // 直接返回专家关联查询页面
                    location.href = ms.manager + "/expertmanage/relation/index";
                }
            },
            mounted: function() {
                // 初始化时添加一个空的专家信息
                this.addExpert();
                
                // 监听窗口大小变化，调整布局
                window.addEventListener('resize', function() {
                    // 这里可以添加响应窗口大小变化的逻辑
                });
            }
        });
        
        // 使用Element Plus组件
        for (const [key, component] of Object.entries(ElementPlus)) {
            app.component(key, component);
        }
        
        // 挂载应用
        app.mount('#form-app');
    });
</script>
</body>
</html> 